package com.gfm.story.controller;

import com.gfm.story.entity.user.User;
import com.gfm.story.result.ResultMsg;
import org.apache.commons.lang3.StringUtils;

/**
 * 用户信息验证处理
 *
 * @author Administrator
 */
public class UserHelper {

    public static ResultMsg validate(User user) {
        if (StringUtils.isBlank(user.getEmail())) {//为空
            return ResultMsg.errorMsg("Email 有误");
        }
        if (StringUtils.isBlank(user.getUsername())) {//为空
            return ResultMsg.errorMsg("账号有误");
        }
        if (StringUtils.isBlank(user.getConfirmPasswd()) || StringUtils.isBlank(user.getPassword()) || !user.getPassword().equals(user.getConfirmPasswd())) {//为空
            return ResultMsg.errorMsg("密码有误");
        }
        if (user.getPassword().length() < 6) {
            return ResultMsg.errorMsg("密码长度需大于6位");
        }
        return ResultMsg.successMsg("");//验证成功返回空字符串
    }

}
